package cn.k.domain;

import com.alibaba.fastjson.JSON;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;

@Getter
@Setter
public class Appointment {

    public static final int STATUS_TYPE_APPOINT = 0;  //预约中、待确定
    public static final int STATUS_TYPE_PERFORM = 1;  //履行中
    public static final int STATUS_TYPE_CONSUME = 2;  //消费中
    public static final int STATUS_TYPE_PLACEON = 3;  //归档中
    public static final int STATUS_TYPE_ABANDON = 4;  //废弃



    /** 主键*/
    private Long id;

    /** 预约单流水号*/
    private String ano;

    /** 预约单状态 （预约中/履行中/消费中/归档/废弃单）*/
    private Integer status=STATUS_TYPE_APPOINT;

    /** 业务大类*/
   // private Long categoryId;
    private SystemDictionary category;

    /** 预约说明*/
    private String info;

    /** 联系电话*/
    private String contactTel;

    /** 联系人名称*/
    private String contactName;

    /** 预约门店*/
    //private Long businessId;
    private Business business;

    /** 创建时间*/
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date createTime;

    /** 预约时间*/
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date appointmentTime;

    public String getStatusDisplay(){
        switch (status){
            case STATUS_TYPE_APPOINT :return "待确认";
            case STATUS_TYPE_PERFORM :return "履行中";
            case STATUS_TYPE_CONSUME :return "消费中";
            case STATUS_TYPE_PLACEON :return "归档中";
            case STATUS_TYPE_ABANDON :return "废弃";
            default: return "异常";
        }
    }

    public String toJson(){
        HashMap<String, Object> map = new HashMap<>();
        map.put("id",id);
        map.put("status",status);
        map.put("contactName",contactName);
        map.put("contactTel",contactTel);
        map.put("businessId",business.getId());
        map.put("info",info);
        map.put("categoryChildId",category.getId());
        map.put("categoryParentId",category.getParentId());
        //map.put("categoryParentName",category.getParentName());
        map.put("appointmentTime",new SimpleDateFormat("yyyy-MM-dd").format(appointmentTime));
        return JSON.toJSONString(map);
    }



}